<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>友情链接列表 - bjyadmin</title>
    <link rel="stylesheet" href="__ADMIN_STATICS__/bootstrap/dist/css/bootstrap.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/animate.css/animate.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/font-awesome/css/font-awesome.min.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/simple-line-icons/css/simple-line-icons.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/bootstrap-editable/css/bootstrap-editable.min.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/app/css/font.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/app/css/app.css" type="text/css" />
</head>
<body>
<div class="wrapper-md">
    <div class="panel panel-default">
        <div class="panel-heading">
            <div class="row">
                <div class="col-sm-3">
                    <a href="{:U('Admin/Index/welcome')}"><i class="fa fa-home"></i>&nbsp;首页</a>&nbsp;&gt;&nbsp;&nbsp;关键字列表
                </div>
            </div>
        </div>
        <div class="panel-body">
             <form action="{:U('Admin/WeiXin/index')}" method="post">
                名称：<input type="text" name="keyword" value="{$keyword}" class="form-control input-sm w-sm inline m-r v-middle"/>
                <button type="submit" class="btn btn-sm btn-default">搜索</button>
                 <span class="pull-right">
                    <a class="btn btn-primary btn-sm menu-add" href="{:U('Admin/WeiXin/addkw')}">添加关键字</a>
                    <button type="button" class="btn btn-danger btn-sm menu-add" onclick="batchDelete()">删除选中</button>
                </span>
            </form>
        </div>
        <div class="table-responsive">
            <table class="table table-bordered table-striped table-hover table-condensed b-t b-light">
                <thead>
                    <tr>
                        <th>关键字</th>
                        <th>类型</th>
                        <th>内容</th>
                        <th>创建时间</th>
                        <th width="100">是否有效</th>
                        <th width=150>操作</th>
                        <th width="10">
                            <label class="i-checks">
                                <input type="checkbox" onclick="$('input[name*=\'delids\']').prop('checked', this.checked);">
                                <i></i>
                            </label>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <volist name="data" id="v">
                        <tr>
                            <td>{$v['_name']}</td>
                            <td>
                                <switch name="v['type']">
                                    <case value="1">文本回复</case>
                                    <case value="2">图片回复</case>
                                    <case value="3">语音回复</case>
                                    <case value="4">视频回复</case>
                                    <case value="5">音乐回复</case>
                                    <case value="6">图文回复</case>
                                    <case value="7">退出当前</case>
                                    <case value="8">应用接口</case>
                                </switch>
                            </td>
                            <td>{$v['content']|re_substr=###,0,50}</td>
                            <td>{$v['create_time'] | date="Y-m-d",time(###)}</td>
                            <td class="text-center" data-id="{$v['id']}" data-type="display" onclick="edit(this)">
                                <a href="javascript:void(0);" class="{$v['is_use'] == 1 ? 'active' : ''}"><i class="fa fa-check text-success text-active"></i><i class="fa fa-times text-danger text"></i></a>
                            </td>
                            <td>
                                <!-- <button type="button" onclick="preview(this)" logo="{$v['logo']}" class="btn btn-default btn-xs" <if condition="$v['logo'] eq null">disabled</if>>预览</button> -->
                                <a class="btn btn-info btn-xs" href="{:U('Admin/WeiXin/editkw',array('id'=>$v['id']))}">修改</a>
                                <a class="btn btn-danger btn-xs" href="javascript:if(confirm('确定删除？'))location='{:U('Admin/WeiXin/deletekw',array('id'=>$v['id']))}'">删除</a>
                            </td>
                            <td>
                                <label class="i-checks">
                                    <input type="checkbox" name="delids" value="{$v['id']}">
                                    <i></i>
                                </label>
                            </td>
                        </tr>
                    </volist>
                </tbody>
            </table>
        </div>
        <!-- <footer class="panel-footer">
            <div class="row text-center">
            {$page}
            </div>
        </footer> -->
    </div>
</div>
<div class="modal fade" id="bjy-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
         <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    友情链接logo预览
                </h4>
            </div>
            <div class="modal-body">
                <img src='' class="b b-a wrapper-xs bg-white img-responsive">
            </div>
        </div>
    </div>
</div>
<script src="__ADMIN_STATICS__/jquery/jquery.min.js"></script>
<script src="__ADMIN_STATICS__/bootstrap/dist/js/bootstrap.js"></script>
<script type="text/javascript">
function batchDelete(){
    var ids = [];
    $("input[name='delids']").each(function(){
        if ($(this).is(':checked') == true){
            var id = $(this).val();
            ids.push(id);
        }
    });
    if(ids.length > 0){
        location.href="/index.php?m=Admin&c=WeiXin&a=batchDelete&ids="+ids;
    }else{
        alert('请选择要删除的关键字');
    }
}

function edit(obj) {
    var id = $(obj).attr('data-id');
    var type = $(obj).attr('data-type');
    var a = $(obj).find('a');
    var param = 0;
    if(a.hasClass('active')){
        param = 0;
    }else{
        param = 1;
    }
    $.ajax({
        url : "{:U('Admin/WeiXin/editkwAjax')}",
        data : {id : id, type : type, param : param},
        dataType : "json",
        type : "post",
        success:function(data){
            if(data.code){
                a.toggleClass('active');
            }
        }
    });
}

function preview(obj){
    $('#bjy-edit img').attr('src', $(obj).attr('logo'));
    $('#bjy-edit').modal('show');
}
</script>
</body>
</html>
